--[[
* 伤害波动
*]]
---@class BuffEffect76 : BaseBuffEffect
BuffEffect76 = ClientFight.CreateClass("BuffEffect76", ClientFight.BaseBuffEffect)
local t = BuffEffect76
---@param fight Fight
---@param buff FighterBuff

function t:action(fight, buff, ...)
    local result = parameters[3];
    if (result:isDamage())then
        return IBuffEffect.FAIL;
    end
    if ( not AttackUtils.isDamage(result.state))then
        return IBuffEffect.FAIL;
    end
    local buffEffectValue = buff.buffBean.f_BuffEffectValue;
    local weightRatio = buffEffectValue[1] + buffEffectValue[3];
    local random = RandomUtils.nextInt(10000) + 1;
    if (random > weightRatio)then
        return IBuffEffect.FAIL;
    end
    if (random <= buffEffectValue[1]) then
        local ratio = buffEffectValue[2] * buff.overlay;
        local damage = calcRatio(result.damage, ratio);
        result.damage = result.damage + damage;
        --LogUtil.info(fight, ()-> "[" + fight.getFrame() + "][EFFECT]Fighter " + buff.getTarget().getFighterId() + " Buff" + buff.getModelId() + " 触发伤害波动, 增加伤害效果 , 总伤害：" + result.damage+" 额外附加: "+damage +" 伤害加成系数: "+ratio+" %%");
    else
        local ratio = buffEffectValue[4] * buff.overlay;
        local damage = calcRatio(result.damage, ratio);
        result.setDamage(result.damage - damage);
        --LogUtil.info(fight, ()-> "[" + fight.getFrame() + "][EFFECT]Fighter " + buff.getTarget().getFighterId() + " Buff" + buff.getModelId() + " 触发伤害波动, 减少伤害效果 , 总伤害：" + result.damage+" 额外附加: -"+ damage +" 伤害加成系数: "+ratio+" %%");
    end
    return ClientFight.BaseBuffEffect.action(self, fight, buff, parameters);
    end

    t.New()